home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / net / spakparnet_0_5.lha / han / act_waitchar.c < prev    next >
C/C++ Source or Header  |  1992-11-09  |  3KB  |  91 lines

  1. /********************************************************************
  2.  ** NETWORK FILESYSTEM - DOS HANDLER
  3.  **
  4.  ** (c) Spak, Darrell Tam, c9107253@ee.newcastle.edu.au (1994)
  5.  ** phone (Australia) 049-829-710
  6.  **                    49-829-710
  7.  ** (c) SST 1994
  8.  **
  9.  ** WAITCHAR
  10.  **
  11.  ** TABS to 4
  12.  ********************************************************************/
  13.  
  14. #include "/snd/everything.h"
  15. #include "deadheads.h"
  16. #include "root_protos.h"
  17. #include "globs_protos.h"
  18. #include "xtra_protos.h"
  19.  
  20. #define WAITCHAR_PKTMSG_SIZE (sizeof(struct WaitCharPktMsg))
  21.  
  22. /** another variation of the "doofus" for waitcharing */
  23. struct WaitCharPktMsg {
  24.     struct DoofusPktMsg    dpm;
  25.  
  26.     struct    NFSWaitChar            waitcharreq;    /* request packet struct */
  27.     struct    NFSStdReturn        waitcharret;    /* what the server sends back */
  28. };
  29.  
  30.  
  31. #define WAITCHAR_PKTMSG_SIZE (sizeof(struct WaitCharPktMsg))
  32.  
  33. /********************************************************************/
  34. static long handle_waitchar_net(struct WaitCharPktMsg *spm)
  35. /********************************************************************/
  36. {
  37. struct DosPacket *dosmsg = spm->dpm.dp_original;
  38.     dosmsg->dp_Res1 = spm->waitcharret.remote_res1;
  39.     dosmsg->dp_Res2 = spm->waitcharret.remote_res2;
  40.     if(spm->dpm.net.pm.smsg.result != PAR_OK)
  41.         { dosmsg->dp_Res1 = 0; dosmsg->dp_Res2 = ERROR_NO_DISK; }
  42.  
  43.     return(AR_FLAG_RETURNDOSMSG | AR_FLAG_FREEDOOF);
  44. }
  45.  
  46.  
  47. /********************************************************************/
  48.    long action_wait_char(struct DosPacket *dosmsg,
  49.                                 struct MsgPort *dm_retport)
  50. /********************************************************************/
  51. { /* timeout, arg1 : actual length */
  52. struct FileArg1 *fa1 = (void *)dosmsg->dp_Arg2;        /* <-- reversed! */
  53. struct WaitCharPktMsg *spm;
  54.  
  55. {    unsigned char tt[100]; spf(tt,100,"fa1=%lx, timeout=%ld",
  56.             dosmsg->dp_Arg2, dosmsg->dp_Arg1); MyPrint(win1, tt);
  57. }
  58.  
  59. /** CHECK THIS FILE ARG1 */
  60.     if(!fa1) {
  61.         dosmsg->dp_Res1 = 0; dosmsg->dp_Res2 = ERROR_INVALID_LOCK;
  62.         return(AR_FLAG_RETURNDOSMSG);
  63.     }
  64.  
  65. /** SEND OFF TO THE REMOTE MACHINE */
  66.     if(!(spm = AllocMem(WAITCHAR_PKTMSG_SIZE, MEMF_PUBLIC))) {
  67.         dosmsg->dp_Res1 = 0; dosmsg->dp_Res2 = ERROR_NO_FREE_STORE;
  68.         return(AR_FLAG_RETURNDOSMSG);
  69.     }
  70.     spm->waitcharreq.request     = REQUEST_WAITCHAR;
  71.     spm->waitcharreq.remote_ifh = fa1->remote.remote_ifh;
  72.     spm->waitcharreq.remote_majic = fa1->remote.majic;
  73.     spm->waitcharreq.timeout    = dosmsg->dp_Arg1;            /* note; NOT ARG2!! */
  74.  
  75.     INIT_DOOFPKTMSG(&spm->dpm,
  76.                 handle_waitchar_net,                        /* our routine to call */
  77.                 netrepport,
  78.                 dosmsg, dm_retport,                            /* original stuff */
  79.                 WAITCHAR_PKTMSG_SIZE,
  80.                 fa1->remote.machine, fa1->remote.service,
  81.                 &spm->waitcharreq, sizeof(struct NFSWaitChar),        /* net-service-request */
  82.                 NULL, 0,                                    /* send-body */
  83.                 NULL, 0,                                    /* result-body */
  84.                 &spm->waitcharret, sizeof(struct NFSStdReturn));
  85.                                                             /* return stuff */
  86.     PutMsg(NET_SERV_PORT(fa1), spm);
  87.     return(0);
  88. }
  89.  
  90.  
  91.